#include <vector>
using namespace std;

class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int left = 0, right = 0, sum = 0, len = INT_MAX;
        for (;right < nums.size();right++)
        {
            sum += nums[right];
            while (sum >= target)
            {
                if (right - left + 1 < len)
                {
                    len = right - left + 1;
                }
                sum -= nums[left++];
            }
        }

        if (len == INT_MAX)
            return 0;
        else
            return len;
    }
};

int main()
{
    vector<int> v = { 1,2,3,4,5 };
    Solution s;
    s.minSubArrayLen(15, v);
    return 0;
}